package com.lemon.smartsafety.ui.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by Cooliean on 16/4/12.
 */
public class ViewPagerEnableScroll extends ViewPager {
    private boolean scrollAble = true;

    public ViewPagerEnableScroll(Context context) {
        super(context);
    }

    public ViewPagerEnableScroll(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void scrollTo(int x, int y) {
        if (scrollAble) {
            super.scrollTo(x, y);
        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (!scrollAble) {
            return true;
        }
        return super.onTouchEvent(ev);
    }


    public boolean isScrollable() {
        return scrollAble;
    }

    public void setScrollable(boolean scrollable) {
        this.scrollAble = scrollable;
    }
}
